﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Dialog : MonoBehaviour
{
    [Header("提示框")]
    public GameObject runDialog;
    public GameObject jumpDialog;
    public GameObject doubleJumpDialog;
    public GameObject crouchDialog;
    public GameObject oneWayPlatformDialog;
    public GameObject dashDialog;
    public GameObject enemyDialog;
    public GameObject enterDialog;
    public GameObject outDialog;
    public GameObject sign_final;
    public GameObject signForFinal;
    public GameObject Final;
    void Update()
    {
        if (enterDialog.activeInHierarchy && Input.GetKeyDown(KeyCode.E))
        {
            LoadManager_Level.instance.LoadEvent();
        }

        else if (outDialog.activeInHierarchy && Input.GetKeyDown(KeyCode.E))
        {
            LoadManager_Level.instance.LoadEvent();
        }
        else if (Final.activeInHierarchy && Input.GetKeyDown(KeyCode.E))
        {
            LoadManager_Level.instance.LoadEvent();
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Run")
        {
            runDialog.SetActive(true);
        }
        else if (collision.tag == "Jump")
        {
            jumpDialog.SetActive(true);
        }
        else if (collision.tag == "DoubleJump")
        {
            doubleJumpDialog.SetActive(true);
        }
        else if (collision.tag == "Crouch")
        {
            crouchDialog.SetActive(true);
        }
        else if (collision.tag == "OneWayPlatform")
        {
            oneWayPlatformDialog.SetActive(true);
        }
        else if (collision.tag == "Dash")
        {
            dashDialog.SetActive(true);
        }
        else if (collision.tag == "KillEnemy")
        {
            enemyDialog.SetActive(true);
        }
        else if (collision.tag == "final")
        {
            sign_final.SetActive(true);
        }
        else if (collision.tag == "SignForFinal")
        {
            signForFinal.SetActive(true);
        }

        //终点
        else if (collision.tag == "FinalDoor")
        {
            Final.SetActive(true);
        }

        //出入口Dialog
        else if (collision.tag == "Entrance")
        {
            enterDialog.SetActive(true);
        }

        else if (collision.tag == "Export")
        {
            outDialog.SetActive(true);
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.tag == "Run")
        {
            runDialog.SetActive(false);
        }
        else if (collision.tag == "Jump")
        {
            jumpDialog.SetActive(false);
        }
        else if (collision.tag == "DoubleJump")
        {
            doubleJumpDialog.SetActive(false);
        }
        else if (collision.tag == "Crouch")
        {
            crouchDialog.SetActive(false);
        }
        else if (collision.tag == "OneWayPlatform")
        {
            oneWayPlatformDialog.SetActive(false);
        }
        else if (collision.tag == "Dash")
        {
            dashDialog.SetActive(false);
        }
        else if (collision.tag == "KillEnemy")
        {
            enemyDialog.SetActive(false);
        }
        else if (collision.tag == "final")
        {
            sign_final.SetActive(false);
        }
        else if (collision.tag == "SignForFinal")
        {
            signForFinal.SetActive(false);
        }
        //终点
        else if (collision.tag == "FinalDoor")
        {
            Final.SetActive(false);
        }

        //入口Dialog
        else if (collision.tag == "Entrance")
        {
            enterDialog.SetActive(false);
        }
        else if (collision.tag == "Export")
        {
            outDialog.SetActive(false);
        }
    }


}
